from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge
from selenium.webdriver.common.keys import Keys
if __name__ == '__main__':
    opt = EdgeOptions()
    opt.use_chromium = True
    opt.add_argument("--headless")
    opt.add_argument("--disable-gpu")
    web = Edge(options=opt)
    web.get('https://www.bilibili.com/')
    web.find_element_by_xpath(
        '//*[@id="nav_searchform"]/input').send_keys('python', Keys.ENTER)
    web.switch_to.window(web.window_handles[-1])
    li_list = web.find_elements_by_xpath(
        '//*[@id="all-list"]/div[1]/div[2]/ul[2]/li')
    for li in li_list:
        title = li.find_element_by_xpath('./div/div[1]/a').text
        print(title)
    web.close()
    web.switch_to.window(web.window_handles[0])
    web.close()
